﻿'use strict';
app.controller('ReferralsController', ['$rootScope', '$scope', '$http', '$modal', '$state', '$localStorage', 'commonFactory',
    function ($rootScope, $scope, $http, $modal, $state, $localStorage, commonFactory){    
        $scope.title = "Sponsor bonus",
        $scope.messeger = "",
        $scope.List = [],
        $scope.popup = function (windowClass, StyleModal, Controller, size) {
            $modal.open({
                windowClass: windowClass,
                templateUrl: StyleModal,
                controller: Controller,
                size: size,
                resolve: {
                    messeger: function () {
                        return $scope.messeger;
                    },
                    title: function () {
                        return $scope.title;
                    }
                }
            })
        },
        getList($localStorage.user.UserId);
        function getList(userId) {
            commonFactory.getListProfit(userId).then(
                function successCallback(resp) {
                    $scope.List = resp.data.Result;
                    $scope.totalItems = $scope.List.length;
                    $scope.itemsPerPage = 12;
                    $scope.currentPage = 1;

                    $scope.setPage = function (pageNo) {
                        $scope.currentPage = pageNo;
                    };

                    $scope.pageChanged = function () {
                        $log.log('Page changed to: ' + $scope.currentPage);
                    };

                    $scope.maxSize = 150;
                    $scope.bigTotalItems = 5000;
                    $scope.bigCurrentPage = 1;

                }, function errorCallback(resp) {
                    $scope.messeger = "";
                    console.log(resp)
                })
        };
}])

